<?php

/**
 * Compras form.
 *
 * @package    tercermilenio
 * @subpackage form
 * @author     Your name here
 */
class BuscarProductosFormFilter extends BaseProductosFormFilter {

    public function configure() {

    }

    public function setup() {
        parent::setup();
        $this->setWidgets(array(
            'pro_articulo' => new sfWidgetFormFilterInput(array('label' => 'Nº Art.', 'with_empty' => false)),
            'pro_talle' => new sfWidgetFormFilterInput(array('label' => 'Talle', 'with_empty' => false)),
            //'pro_precio'           => new sfWidgetFormFilterInput(),
            //'pro_cantidad'         => new sfWidgetFormFilterInput(),
            //'pro_ganancia'         => new sfWidgetFormFilterInput(),
            'pro_descripcion' => new sfWidgetFormFilterInput(array('label' => 'Descripción', 'with_empty' => false)),
                //'pro_marca'            => new sfWidgetFormPropelChoice(array('model' => 'Marcas', 'add_empty' => true)),
                //'pro_rubro'            => new sfWidgetFormPropelChoice(array('model' => 'Rubros', 'add_empty' => true)),
                //'pro_proveedor'        => new sfWidgetFormPropelChoice(array('model' => 'Proveedores', 'add_empty' => true)),
                //'devoluciones_list'    => new sfWidgetFormPropelChoice(array('model' => 'Ventas', 'add_empty' => true)),
                //'detalle_ventas_list'  => new sfWidgetFormPropelChoice(array('model' => 'Ventas', 'add_empty' => true)),
                //'detalle_compras_list' => new sfWidgetFormPropelChoice(array('model' => 'Compras', 'add_empty' => true)),
        ));

        $this->setValidators(array(
            'pro_articulo' => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
            'pro_talle' => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
            //'pro_precio'           => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
            //'pro_cantidad'         => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
            //'pro_ganancia'         => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
            'pro_descripcion' => new sfValidatorPass(array('required' => false)),
                //'pro_marca'            => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Marcas', 'column' => 'mar_id')),
                //'pro_rubro'            => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Rubros', 'column' => 'rub_id')),
                //'pro_proveedor'        => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Proveedores', 'column' => 'pvd_id')),
                //'devoluciones_list'    => new sfValidatorPropelChoice(array('model' => 'Ventas', 'required' => false)),
                //'detalle_ventas_list'  => new sfValidatorPropelChoice(array('model' => 'Ventas', 'required' => false)),
                //'detalle_compras_list' => new sfValidatorPropelChoice(array('model' => 'Compras', 'required' => false)),
        ));

        $this->widgetSchema->setNameFormat('productos_filters[%s]');

        $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
    }

    /* public function addDescripcionColumnCriteria(Criteria $criteria, $values, $field){
      var_dump($values['text']);
      if(!empty($values)){
      $criteria->add(ProductosPeer::PRO_DESCRIPCION, '%'.$values.'%',Criteria::LIKE);
      $criteria->addJoin(ProductosPeer::PRO_ARTICULO, DetalleComprasPeer::DET_CPR_ARTICULO);
      $criteria->addJoin(ProductosPeer::PRO_TALLE, DetalleComprasPeer::DET_CPR_TALLE);
      }
      } */
}
